<import file="block/common.html" name="url" :tpl_cfg="['urlName'=>$title,'backList'=>'返回列表']"/>
<div class="layui-fluid">
    <div class="layui-form">
		<div class="layui-form-item">
            <label class="layui-form-label required">上级栏目</label>
            <div class="layui-input-inline layui-col-md4">
					<select name="pid" lay-verify="">
					 <option value="0">顶级栏目</option>
					<?php foreach($list as $key=>$vo){?>
					  <option value="<{$vo['id']}>" <?php if(!empty($info)){if($info['pid'] == $vo['id']){echo "selected";}  if($vo['id']==$_GET['id']){echo "disabled";}} ?>><{$vo['cname']}></option>
					<?php }?>
					</select>  
            </div>
            <div class="layui-form-mid layui-word-aux">选择上级栏目</div>
        </div>
		<div class="layui-form-item">
            <label class="layui-form-label required">栏目名称</label>
            <div class="layui-input-inline">
                <input type="text" name="name" lay-verify="required" lay-reqtext="名称不能为空" placeholder="请输入名称" value="<{$info['name']??''}>" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">一般 为中文 如：后台首页</div>
        </div>
		<div class="layui-form-item">
			<label class="layui-form-label">栏目类型</label>
			<div class="layui-input-inline">
			  <input type="radio" name="type" value="1" title="列表" <?php if(!empty($info)){if($info['type'] == 1){echo "checked";}}?>>
			  <input type="radio" name="type" value="0" title="频道" <?php if(!empty($info)){if($info['type'] == 0){echo "checked";}}?>>
			</div>
          </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">本级排序</label>
            <div class="layui-input-inline">
                <input type="text" name="sort" placeholder="请输入本级排序数字" value="<{$info['sort']??''}>" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">本级栏目中的排序 数字如： 2 ，数字越小，越前</div>
        </div>
       
        <div class="layui-form-item">
            <label class="layui-form-label required">栏目模板</label>
            <div class="layui-input-inline layui-col-md4">
					<select name="theme" lay-verify="">
					 <option value="">默认模板</option>
					<?php foreach($templist as $key=>$vo){?>
					  <option value="<{$vo}>" <?php if(!empty($info)){if($info['theme'] == $vo){echo "selected";}} ?>><{$vo}></option>
					<?php }?>
					</select>  
            </div>
            <div class="layui-form-mid layui-word-aux">默认模板为index.html 定制模板位置： \app\index\view\default\contents\ </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">内容模板</label>
            <div class="layui-input-inline layui-col-md4">
					<select name="contheme" lay-verify="">
					 <option value="">默认模板</option>
					<?php foreach($sontemplist as $key=>$vo){?>
					  <option value="<{$vo}>" <?php if(!empty($info)){if($info['contheme'] == $vo){echo "selected";}} ?>><{$vo}></option>
					<?php }?>
					</select>  
            </div>
            <div class="layui-form-mid layui-word-aux">默认模板为index.html 定制模板位置： \app\index\view\default\content\ </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">显示条数</label>
            <div class="layui-input-inline">
                <input type="text" name="num" placeholder="请输入数字" value="<{$info['num']??''}>" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">前台栏目列表每页显示内容条数 数字如：25</div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">图标</label>
            <div class="layui-input-inline" style="width:300px;">
               <input type="text" class="icoSelect" placeholder="选择图标" name="ico" value="<{$info['ico']??''}>" lay-verify="required" lay-reqtext="图标不能为空">
            </div>
            <span class="layui-form-mid layui-word-aux" id="iconame"><{$info['ico']??''}></span>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">栏目颜色</label>
            <div class="layui-input-inline" style="width: 120px;">
              <input type="text" name="color" value="<{$info['color']??''}>" placeholder="请选择颜色" class="layui-input" id="colorpicker">
            </div>
            <div class="layui-inline" style="left: -11px;">
              <div id="colorpicker-form"></div>
            </div>
        </div>
        <div class="layui-form-item">
			<label class="layui-form-label">统计开关</label>
			<div class="layui-input-inline">
			  <input type="radio" name="ct" value="1" title="统计" <?php if(!empty($info)){if($info['ct'] == 1){echo "checked";}}?>>
			  <input type="radio" name="ct" value="0" title="不统计" <?php if(!empty($info)){if($info['ct'] == 0){echo "checked";}}?>>
            </div>
            <div class="layui-form-mid layui-word-aux">是否加入当前栏目发布量统计</div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label required">URL</label>
            <div class="layui-input-inline">
                <input type="text" name="urlname"  value="<{$info['urlname']??''}>" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">前台访问本栏目的URL 地址 留空 默认为ID 如：news</div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
			<input type="hidden" name="id" value="<{$info['id']??''}>">
                <button class="layui-btn" lay-submit lay-filter="saveBtn"><i class="layui-icon">&#x1005;</i><?php echo lang('save');?></button>
            </div>
        </div>
    </div>
</div>
<script>
layui.define(["iconSelected"], function () {
        var form = layui.form,layer = layui.layer,colorpicker = layui.colorpicker,iconSelected = layui.iconSelected;
        
        form.render();

        iconSelected.render(".icoSelect", {
            event: {
                select(event, data) {
                    $('#iconame').text(data.icon);
                    //console.log("选中的图标数据", { event, data });
                },
            },
        });
        
        colorpicker.render({
            elem: '#colorpicker-form'  //绑定元素
            ,color: '<{$info["color"]??"#9d8a0e"}>'
            ,predefine: true
            ,colors:['#4dc9f6','#f67019','#f53794','#537bc4','#acc236','#166a8f','#00a950','#58595b','#8549ba']
            ,done: function(color){
                $('#colorpicker').val(color);
            }
        });   

        
        form.on('submit(saveBtn)', function (data) {
			$.post('<{CAUrl("contentcate",ROUTE["act"])}>',data.field,function(res){
                if(res.status == 1){
                    layer.msg(res.info, {icon: 1, time: 1000},function(){
						loadMain('<{CAUrl("contentcate","index")}>');
					});
                }else{
                    layer.msg(res.info, {icon: 2, anim: 6, time: 5000});
                }
            });
            return false;
        });
    });
</script>